package com.zyy.meetObject;

public class StudentTest {
    public static void main(String[] args){
        //创建Student[]
        Student[] student = new Student[20];

        //使用循环，给数组的元素赋值
        for(int i = 0; i < student.length ; i ++){
            student[i] = new Student();
            student[i].number = (i + 1);
            student[i].score = (int)(Math.random()*101);
            student[i].state = (int)(Math.random()* 6 + 1);
        }

        //打印3年级的学生信息：
        for(int i = 0; i < student.length;i++){
            if(student[i].state == 3){
                student[i].show();
            }
        }
        //使用冒泡排序，并遍历所有学生信息：
        for(int i = 0; i < student.length - 1; i++){
            for(int j = 0; j < student.length - i - 1; j ++){
                if(student[j].score > student[j + 1].score){
                    Student temp = student[j];
                    student[j] = student[j + 1];
                    student[j + 1] = temp;
                }
            }
        }
        for(int i = 0; i < student.length; i++){
            student[i].show();
        }


    }
}
